package com.group8.gm;

import java.awt.Rectangle;
import java.util.Enumeration;
import java.util.Vector;

import com.group8.ge.GameObject;
import com.group8.ge.Noodle;
import com.group8.ge.Plate;

public class CollisionController {
	public boolean checkWithPlates(GameObject obj, Vector<GameObject> objects) {
		//Vector<GameObject> plates = new Vector<GameObject>();
		Enumeration<GameObject> venum = objects.elements();
		
		while(venum.hasMoreElements()){
			GameObject e = (GameObject)venum.nextElement();
			//System.out.println("ilk rectk " + (int)e.getX() + " " + (int)e.getY()+ " " + (int)(e.getWidth()) +" " + (int)e.getHeight());
			//System.out.println("ikinci " + (int)obj.getX() + " "+ (int)obj.getY()+  " "+(int)obj.getWidth() + " " + (int)obj.getHeight());
			Rectangle r = new Rectangle((int)e.getX(),(int)e.getY(),(int)(e.getWidth()),(int)e.getHeight());
		    Rectangle p = new Rectangle((int)obj.getX(),(int)obj.getY()+80,(int)obj.getWidth(),(int)obj.getHeight()-80);
		    // Assuming there is an intersect method, otherwise just hand compare the values
		    if (p.intersects(r))
		    {
		       return true;
		    }
		}
		return false;
	}
	
	public boolean checkWithEnemy(GameObject obj, Vector<GameObject> objects){
		Enumeration<GameObject> venum = objects.elements();
		
		while(venum.hasMoreElements()){
			GameObject e = (GameObject)venum.nextElement();
		    Rectangle r = new Rectangle((int)e.getX(),(int)e.getY(),(int)e.getWidth(),(int)e.getHeight());
		    Rectangle p = new Rectangle((int)obj.getX(),(int)obj.getY(),(int)obj.getWidth(),(int)obj.getHeight());

		    // Assuming there is an intersect method, otherwise just handcompare the values
		    if (r.intersects(p))
		    {
		       return true;
		    }
		}
		
		return false;
	}
	public boolean checkWithBonus(GameObject obj, Vector<GameObject> objects){
		Enumeration<GameObject> venum = objects.elements();
		
		while(venum.hasMoreElements()){
			GameObject e = (GameObject)venum.nextElement();
		    Rectangle r = new Rectangle((int)e.getX(),(int)e.getY(),(int)e.getWidth(),(int)e.getHeight());
		    Rectangle p = new Rectangle((int)obj.getX(),(int)obj.getY(),(int)obj.getWidth(),(int)obj.getHeight());

		    // Assuming there is an intersect method, otherwise just handcompare the values
		    if (r.intersects(p))
		    {
		       return true;
		    }
		}
		
		return false;
	}
}
